<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //1.判断对象是否相同
        // Object.is();

        // let obj1 = {
        //     myname: "张三"
        // }
        // // let obj2 = {
        // //     myname: "张三"
        // // }
        // let obj2 = obj1;
        // // console.log(obj1 === obj2); //false
        // console.log(Object.is(obj1, obj2)); //true

        // console.log(NaN === NaN); //false

        // console.log(Object.is(NaN, NaN)); //true


        //2.Object.assign(); 合并2个或者多个对象  (重点)
        //相同键名会覆盖
        //是一个浅拷贝
        // let obj1 = {
        //     name: "张三"
        // }
        // let obj2 = {
        //     age: 20,
        //     // name:"李四"// {name: '李四', age: 20, height: '178cm'}
        // }
        // let obj3 = {
        //     height: "178cm"
        // }
        // let res = Object.assign(obj1, obj2, obj3);
        // console.log(res); //{name: '张三', age: 20, height: '178cm'}
        // obj1.name = "王五";
        // console.log(res); // {name: '王五', age: 20, height: '178cm'}


        //展开运算符  复制的对象或者数组  也是浅拷贝
        // let arr = [1, 2, 3, [6, 7]];
        // let arr2 = [...arr];
        // arr[0] = 5;
        // arr[3][0] = 8
        // console.log(arr2); //[1,2,3,[8,7]]

        //3.Object.hasOwn  //es6 判断某个属性是否是对象的自身属性 (重点)
        // obj.hasOwnProperty("key") //ES5
        // let obj = {
        //     myname: "张三",
        //     age: 20
        // }
        // console.log(Object.hasOwn(obj, "age")); //true

        //Object.keys();  Object.values();  (重点)
        //获取对象的所有键名  或者键值  放在一个数组里
        // let obj ={
        //     myname:"张三",
        //     age:20
        // }   
        // let keys = Object.keys(obj);
        // console.log(keys);//['myname', 'age']
        // let values = Object.values(obj);
        // console.log(values);//['张三', 20]


        //5.Object.seal(); 可以把对象  变成不可配置对象
        let obj = {
            myname: "张三",
            age: 20
        }
        Object.seal(obj);
        // // Object.freeze(obj);
        obj.myname = "李四";
        console.log(obj); // {myname: '李四', age: 20}

        delete obj.myname;
        console.log(obj); //{myname: '李四', age: 20}
    </script>
</body>

</html>